package testUI;

import java.io.FileInputStream;
import java.io.FileNotFoundException;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.IconAndMessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;

class WizardDetail extends IconAndMessageDialog {
//	WizardDetail a = new WizardDetail(shell);
//	a.open();
	
  public static final int MyID = IDialogConstants.CLIENT_ID;

  public static final String MyLABEL = "Custom";
  private Image image;

  private Label label;

  public WizardDetail(Shell parent) {
    super(parent);
    try {
      image = new Image(parent.getDisplay(), new FileInputStream("images/loser.gif"));
    } catch (FileNotFoundException e) {
    }
    message = "message";
  }

  public void setMessage(String message) {
    this.message = message;
  }
  public boolean close() {
    if (image != null)
      image.dispose();
    return super.close();
  }

  protected Control createDialogArea(Composite parent) {
    createMessageArea(parent);
    Composite composite = new Composite(parent, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    composite.setLayoutData(data);
    composite.setLayout(new FillLayout());

    label = new Label(composite, SWT.LEFT);
    return composite;
  }

  protected void createButtonsForButtonBar(Composite parent) {
    createButton(parent, IDialogConstants.YES_ID, IDialogConstants.YES_LABEL, true);
    createButton(parent, IDialogConstants.NO_ID, IDialogConstants.NO_LABEL, false);
    createButton(parent, MyID, MyLABEL, false);
  }

  protected void buttonPressed(int buttonId) {
    if (buttonId == MyID) {
      setReturnCode(buttonId);
      close();
    } else {
      label.setText("Yeah, right. You know nothing.");
    }
  }

  protected Image getImage() {
    return image;
  }
}